{include file="public/header"/}
<link rel="stylesheet" href="{__PUBLIC_PATH}/admin/pcf/pcfbase.css?v={$version}"/>
<script src="{__PUBLIC_PATH}/common/js/jquery.js?v={$version}"></script>
<script src="{__PUBLIC_PATH}/admin/pcf/global.js?v={$version}"></script>
</head>
<body>
<style>
.pcfts{font:bold 14px/20px tahoma,verdana;color:#F60;vertical-align:middle;display:inline-block;margin-right:5px;margin-left:-14px;}
</style>
<div class="layui-form" id="LAY-component-layer-list">
<div class="layui-fluid" style="padding-bottom:83px;">
<div class="layui-card pcf30">
<div style="height:100%;max-width:600px;">
    <div class="layui-form-item">
        <label class="layui-form-label"><b class="pcfts">*</b> 模型名称</label>
        <div class="layui-input-block">
         <input type="text" name="ntitle" value="" lay-verify="required" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><b class="pcfts">*</b> 模型标识</label>
        <div class="layui-input-block">
        <input type="text" name="nid" value="" id="nid" lay-verify="required|check_nid" class="layui-input" onkeyup="this.value=this.value.replace(/[^a-z0-9]/g,'');" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^a-z0-9]/g,''));">
        <div class="layui-input-block2" style="padding:10px 0;">
            与文档的模板相关连，建议由小写字母、数字组成，因为部份Unix系统无法识别中文文件。<br/>
            列表模板是：lists_模型标识.html<br/>
            文档模板是：view_模型标识.html
        </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">标题重复</label>
        <div class="layui-input-block">
        <input type="checkbox" lay-filter="is_repeat_title" lay-skin="switch" lay-text="是|否" checked>
        <input type="hidden" name="is_repeat_title" value="1" />
        </div>
        新增/编辑文档时，是否允许标题的重复
    </div>
</div>
<div class="submit-info text-center">
    <button class="layui-btn" lay-submit lay-filter="formSubmit">确认提交</button>
</div>
<div style="clear:both;"></div>
</div>
</div>
</div>
{include file="public/footer"/}
<script>
  layui.use(['layer', 'form'], function () {
     var $ = layui.$,
        layer = layui.layer,
        form = layui.form;
        layer = layui.layer;

        // 监听开关
        form.on('switch', function(data){
          var elemId = data.elem.attributes['lay-filter']['nodeValue'];
          if (data.elem.checked) {
            this.value = 1;
          } else {
            this.value = 0;
          }
          $("input[name='"+elemId+"']").val(this.value);
        });
        
        //监听提交
        form.on('submit(formSubmit)', function(data){
            layer.msg('正在处理请勿刷新页面', {icon: 16,shade: 0.01,time:3600000});
            $.ajax({
                type : 'post',
                url : '{:url("/channel.type/add")}',
                data : data.field,
                dataType : 'json',
                success : function(res){
                    layer.closeAll('loading');
                    if(res.status){
                        layer.msg(res.msg, {icon: 1, time: 1000}, function(){
                            parent.window.location.href = res.url;
                        });
                    }else{
                        layer.msg(res.msg, {icon: 2, time: 1000});
                    }
                },
                error: function(e){
                    layer.closeAll('loading');
                    layer.msg("未知错误，操作中断！", {icon: 2, time: 1000});
                }
            });
            return false;
        })
    });
</script>